﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="Custom_Followup_Add.aspx.cs" Inherits="Admin_Views_Custom_Custom_Followup_Add" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript">
    var isDialogPage = (frameElement != null); //本页面是否是对话框打开的

    if (isDialogPage) {

        // api.opener 为载加lhgdialog.min.js文件的页面的window对象
        // D 为载加lhgdialog.min.js文件的页面的document对象
        //不是lhgdialog打开
        if (typeof (frameElement.api) == "undefined") {
            isDialogPage = false;
        } else {
            var api = frameElement.api, W = api.opener, D = W.document;
        }
    }
    $(function () {
        dark.form({
            appendTo: $(".form2"),
            title: "添加客户跟进",
            data: {},
            width: 900,
            items: [
				{ id: "CustomID", label: "客户昵称", type: "comboBox", width: 180, data: DarkCRM.Models.Custom.GetCustomName().Data, editable: true },
                { id: "CustomFollowupStatus", label: "状态", type: "comboBox", width: 180, data: DarkCRM.Models.CustomFollowupStatus.GetFollowupStatus(0).Data },
                { id: "Note", label: "跟进信息", type: "editor", required: true, width: 700, height: 400 },
                { id: "Property", label: "属性", type: "checkbox", required: true, data: [{ text: "提醒", id: "Remind" }, { text: "机会", id: "IsOpportunity"}] },

                { id: "submit", label: "添加", type: "submit", iconCls: "icon-save", url: "",
                    onClick: function (isValid, formData) {                        
                        dark.dialog.loading("正在验证客户资料...");
                        var isCustomID = dark.isdigit(formData.CustomID)
                        if (isCustomID==false) {
                            dark.dialog.closeLoading();
                            dark.dialog.error("对不起，该客户不存在!");
                        } else {
                            dark.dialog.loading("正在保存资料...");
                            DarkCRM.Models.CustomFollowup.Create(formData, { success: function (result) {
                                dark.dialog.closeLoading();
                                if (result.ErrorCode == 0) {
                                    dark.dialog.successAlter("添加成功!", function () {
                                        if (isDialogPage) {
                                            W.reload(); //刷新parent的grid控件
                                            api.close(); //关闭自己对话框
                                        }
                                    });
                                } else {
                                    dark.dialog.error("对不起，添加失败!");
                                }
                            }
                            });
                        }
                    },
                    success: function (isValid, data) {

                    },
                    onLoadError: function () {
                    }
                }
                ]
        });
    });

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div class="form2">
    </div>
</asp:Content>

